feat: dev/preview platform emulation#11730
Merged
Rich-Harris merged 19 commits intomainfrom Jan 24, 2024
Merged
Conversation
This reverts commit 4a847e4.
🦋 Changeset detectedLatest commit: 8e94317 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5 tasks
benmccann
reviewed
Jan 24, 2024
This was referenced Jan 24, 2024
antony
approved these changes
Jan 24, 2024
Member
antony
left a comment
There was a problem hiding this comment.
I'm sad that it's not shimulate but I'm happy for it.
Merged
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This picks up @dario-piotrowicz' work in #11323 and adds the things discussed in #11323 (comment).
It allows an adapter to provide an
emulatefunction that returns a set of functions for influencing the dev and preview servers. Right now, there's only aplatformfunction, which populatesevent.platform. This is useful for providing access to e.g. KV namespaces in development.TODO:
feat: implementadapter-cloudflare-workersshould also populateplatform.contextandplatform.caches, I think?adapter.emulate#11732do we need a cleanup mechanism? (e.g.not immediately necessarybindingshas adisposemethod that is never called; we just kill the process. maybe that's fine?) if so what would it look like?Future:
emulateandplatformshould be mandatory for adapters that populateplatformin production? Though it wouldn't allow us to remove the?inplatform?: App.Platform, since it's still not populated during prerendering (unless we decide otherwise?)platform, for e.g. adding platform-specific globals/modules, banning certain imports, special platform-specific routes (/_vercelfor image optimisation), etcwrangler.toml)ValidatedKitConfig = RecursiveRequired<KitConfig>, TypeScript thinksadapter.emulateis always present. Not sure how to correct thatPlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits